package com.princess.demok.view

import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.TextView

import com.princess.baselib.utils.LogUtils

/**
 * @author: xha
 * @date: 2021/9/16 11:53
 * @Description:
 */
@SuppressLint("AppCompatCustomView")
class MyTextview : TextView {
    constructor(context: Context) : super(context) {
    }

    constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {

    }

    constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(
        context,
        attributeSet,
        defStyleAttr
    ) {

    }

    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {

//        val isTure = true
//        LogUtils.i("touch", "viewGroup2 dispatchTouchEvent $isTure")
//        return isTure
        LogUtils.i("touch", "view dispatchTouchEvent " + super.dispatchTouchEvent(ev))
        return super.dispatchTouchEvent(ev)
    }

    var sysLong: Long = 0;
    override fun onTouchEvent(event: MotionEvent?): Boolean {

//        val isTure = true
//        LogUtils.i("touch", "viewGroup2 onTouchEvent $isTure")
//        return isTure
        LogUtils.i("touch", "view onTouchEvent " + super.onTouchEvent(event))
        when (event?.action) {
            MotionEvent.ACTION_MOVE -> {
                LogUtils.i("tou", "ACTION_MOVE")
            }
            MotionEvent.ACTION_DOWN -> {
                LogUtils.i("tou", "ACTION_DOWN")
                LogUtils.i("tou", "x " + event.rawX + " y " + event.rawY)

            }
            MotionEvent.ACTION_UP -> {
                LogUtils.i("tou", "ACTION_UP")
            }
            MotionEvent.ACTION_CANCEL -> {
                LogUtils.i("tou", "ACTION_CANCEL")
            }
        }

        return super.onTouchEvent(event)
    }

}